#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    char** data;
    int size;
    int capacity;
} vector;

void append(vector* v, char* sub) {
    if (v->capacity == v->size) {
        if (v->capacity == 0) {
            v->capacity = 4;
        }
        else {
            v->capacity *= 2;
        }
        char** tmp = (char**)realloc(v->data, sizeof(char*) * v->capacity);
        if (tmp != NULL) {
            v->data = tmp;
        }
    }
    char* p = (char*)malloc(sizeof(char) * (strlen(sub) + 1));
    strcpy(p, sub);
    v->data[v->size++] = p;
}

char** splitWordsBySeparator(char** words, int wordsSize, char separator, int* returnSize) {
    const char sep[2] = { separator };
    vector v;
    memset(&v, 0, sizeof(vector));
    for (int i = 0; i < wordsSize; i++) {
        for (const char* sub = strtok(words[i], sep); sub != NULL; sub = strtok(NULL, sep)) {
            if (strlen(sub) != 0) {
                append(&v, sub);
            }
        }
    }
    *returnSize = v.size;
    return v.data;
}

int main()
{
    return 0;
}